package net.ssta.core.util.format;

public class StringArrayFormat extends ValueObjectFormat
{
	public String getString(Object value, String defaultValue) { return value == null ? defaultValue : getString(value, defaultValue, ","); }
	
	public String getString(Object value, String defaultValue, String formatString)
	{
		if( value == null ) return defaultValue;
		String[] array = (String[])value;
		StringBuffer sb = new StringBuffer();
		for(int i=0 ; i<array.length; i++)
		{
			sb.append(array[i]).append(formatString);
		}
		if(sb.length() > formatString.length())
		{
			sb.setLength(sb.length() - formatString.length());
		}
		return sb.toString();
	}

	public String[] getStringArray(Object value)
	{
		return (String[])value;
	}
}
